<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!doctype html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta charset="utf-8">
    <link rel="stylesheet" href="${ctx}/css/sapar.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common.css"/>
    <script type="text/javascript" src="${ctx}/js/jquery.js"></script>
    <script type="text/javascript" src="${ctx}/js/sapar.js"></script>
    <script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
    <script type="text/javascript" src="${ctx}/js/mask.js"></script>
    <title>编辑厂家</title>
    <style>

        #mc {
            width: 100px;
        }

    </style>
</head>

<body>
<div id="mask" class="mask"></div>
<div id="saper-container">
    <div id="saper-hd"></div>
    <div id="saper-bd">
        <div class="subfiled clearfix">
            <h2>编辑厂家</h2>
        </div>
        <div class="subfiled-content">
            <form class="saper-form" id="dataForm">
                <div class="kv-item clearfix">
                    <label id="mc"><span class="impInfo">*</span>厂商分类：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂商分类" class="txt_required" name="manufactorClass"
                               id="manufactorClass" value="${manufactor.manufactorClass}"
                               onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc"><span class="impInfo">*</span>厂家名称：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂家名称" class="txt_required" name="manufactorName"
                               id="manufactorName" value="${manufactor.manufactorName}"
                               onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc"><span class="impInfo">*</span>助记码 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂家助记码 " class="txt_required" name="manufactorCode"
                               id="manufactorCode" value="${manufactor.manufactorCode}"
                               onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc"><span class="impInfo">*</span>厂家电话 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂家电话 " class="txt_required" name="manufactorTel"
                               value="${manufactor.manufactorTel}" maxlength="11"
                               onkeyup="this.value=this.value.replace(/\D/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc">厂家品牌 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂家品牌" name="manufactorBrand"
                               value="${manufactor.manufactorBrand}"
                               onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc">厂家传真 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂家传真" name="manufactorFax" value="${manufactor.manufactorFax}"
                               onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc">厂家地址 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="厂家地址" name="manufactorAddress"
                               value="${manufactor.manufactorAddress}"
                               onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc">厂家负责人 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="负责人" name="manufactorContacts"
                               value="${manufactor.manufactorContacts}">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc">负责人电话 ：</label>
                    <div class="kv-item-content">
                        <input type="text" placeholder="负责人电话" name="manufactorMobile"
                               value="${manufactor.manufactorMobile}" maxlength="11"
                               onkeyup="this.value=this.value.replace(/\D/g,'')">
                    </div>
                </div>
                <div class="kv-item clearfix">
                    <label id="mc">厂家简介 ：</label>
                    <div class="kv-item-content">
                        <textarea style="margin-top:5px;" placeholder="厂家简介"
                                  name="manufactorMark">${manufactor.manufactorMark}</textarea>
                    </div>
                    <div class="kv-item-tip"></div>
                </div>

                <div class="buttons">
                    <a href="javascript:;" class="sapar-btn sapar-btn-recom">确定</a>
                    <input type="hidden" name="manufactorId" id="manufactorId" value="${manufactor.manufactorId}"/>
                    <input type="hidden" name="manufactorNo" id="manufactorNo" value="${manufactor.manufactorNo}"/>
                </div>
            </form>
        </div>
    </div>
    <div id="saper-ft"></div>
</div>

</body>

<script type="text/javascript">
    function isdd() {

    }


    function isNullOrEmpty(strVal) {
        strVal = strVal.replace(/(^\s*)|(\s*$)/g, "");
        if (strVal == '' || strVal == null || strVal == undefined) {
            return true;
        } else {
            return false;
        }
    }


    $(function () {
        $(".sapar-btn-recom").click(function () {
            var btn = true;
            $(".txt_required").each(function () {
                var str = $(this).val();
                //var str = $(this).replace(/(^\s*)|(\s*$)/g,"");
                //alert(str);
                if (isNullOrEmpty(str)) {
                    btn = false;
                    layer.msg("必填项不为空");
                    return false;
                }
            });
            if (btn) {
                showMask();
                $.ajax({
                    type: "POST",
                    url: "${ctx}/manufactor/save.do",
                    data: $('#dataForm').serialize(),// 你的formid
                    error: function (request) {
                        layer.alert("网络故障，请稍后再试!");
                    },
                    success: function (data) {
                        $("#mask").hide();
                        if (data.status == "true") {
                            layer.alert("保存成功", function () {
                                window.location.href = "${ctx}/manufactor/findAllManufactor.do";
                            });
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                });
            }
        });

        $('#manufactorName').change(function () {
            var manufactorName = $('#manufactorName').val();
            /*速记码生成器  */
            $.ajax({
                url: "${ctx}/eng/cn2en.do?msg=" + manufactorName,
                dateType: "json",
                success: function (data) {
                    if (data.status == "true") {
                        $("#manufactorCode").val(data.msg);
                    }
                }
            });
        });
    });
</script>
</html>